﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:xoqalControls="clr-namespace:Xoqal.Presentation.Controls;assembly=Xoqal.Presentation"
                    xmlns:resources="clr-namespace:Shammateh.Resources;assembly=Shammateh.Resources"
                    xmlns:wt="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"
                    xmlns:localControls="clr-namespace:Shammateh.Win.UI.Controls">

    <Style TargetType="UserControl">
        <Setter Property="FontFamily" Value="Tahoma"/>
        <Setter Property="FlowDirection" Value="RightToLeft"/>
    </Style>

    <Style TargetType="Window">
        <Style.Setters>
            <Setter Property="FontFamily" Value="Tahoma"/>
        </Style.Setters>
    </Style>

    <Style x:Key="errorTemplate" TargetType="Control">
        <Style.Triggers>
            <Trigger Property="Validation.HasError" Value="True">
                <Setter Property="ToolTip"
                Value="{Binding RelativeSource={RelativeSource Self},
                            Path=(Validation.Errors)[0].ErrorContent}" />
            </Trigger>
        </Style.Triggers>
        <Setter Property="Validation.ErrorTemplate">
            <Setter.Value>
                <ControlTemplate>
                    <Border BorderBrush="#FFE8D030" BorderThickness="1" CornerRadius="2">
                        <Border.Effect>
                            <DropShadowEffect Color="#FFE8D030" Opacity="0.7" BlurRadius="2" ShadowDepth="0" />
                        </Border.Effect>
                        <AdornedElementPlaceholder />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="FontFamily" Value="Tahoma"/>
    </Style>

    <Style TargetType="ListBox" x:Key="navigationPaneListBox">
        <Style.Resources>
            <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />
            <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" />
        </Style.Resources>
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="Transparent" />
    </Style>

    <Style TargetType="ListBoxItem" x:Key="navigationPaneListBoxItem">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="Height" Value="24" />
    </Style>

    <Style TargetType="{x:Type Hyperlink}" x:Key="navigationPaneHyperLink">
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Foreground" Value="Black" />
            </Trigger>
        </Style.Triggers>
        <Setter Property="Foreground" Value="Black" />
        <Setter Property="TextBlock.TextDecorations" Value="{x:Null}" />
    </Style>

    <LinearGradientBrush x:Key="Brush_HeaderBackground" StartPoint="0.5,0" EndPoint="0.5,1">
        <GradientStop Color="#66000088" Offset="0" />
        <GradientStop Color="#BB000088" Offset="1" />
    </LinearGradientBrush>

    <Style x:Key="defaultButton" TargetType="Button">
        <Setter Property="Margin" Value="2" />
        <Setter Property="Padding" Value="7,0" />
        <Setter Property="FontFamily" Value="Tahoma"/>
    </Style>

    <Style x:Key="cancelButton" TargetType="Button" BasedOn="{StaticResource defaultButton}">
        <Setter Property="Content" Value="{x:Static resources:Resource.Cancel}" />
        <Setter Property="IsCancel" Value="True" />
        <Setter Property="Width" Value="62" />
    </Style>

    <Style x:Key="acceptButton" TargetType="Button" BasedOn="{StaticResource defaultButton}">
        <Setter Property="Content" Value="{x:Static resources:Resource.Save}" />
        <Setter Property="IsDefault" Value="True" />
        <Setter Property="Width" Value="62" />
    </Style>

    <Style x:Key="addButton" TargetType="Button" BasedOn="{StaticResource defaultButton}">
        <Setter Property="Content" Value="{x:Static resources:Resource.Add}" />
        <Setter Property="Width" Value="62" />
    </Style>

    <Style x:Key="editButton" TargetType="Button" BasedOn="{StaticResource defaultButton}">
        <Setter Property="Content" Value="{x:Static resources:Resource.Edit}" />
        <Setter Property="Width" Value="62" />
    </Style>

    <Style x:Key="deleteButton" TargetType="Button" BasedOn="{StaticResource defaultButton}">
        <Setter Property="Content" Value="{x:Static resources:Resource.Delete}" />
        <Setter Property="Width" Value="62" />
    </Style>

    <Style x:Key="loginButton" TargetType="Button" BasedOn="{StaticResource defaultButton}">
        <Setter Property="Content" Value="{x:Static resources:Resource.Login}" />
        <Setter Property="IsDefault" Value="True" />
    </Style>

    <Style x:Key="exitButton" TargetType="Button" BasedOn="{StaticResource defaultButton}">
        <Setter Property="Content" Value="{x:Static resources:Resource.Exit}" />
        <Setter Property="IsCancel" Value="True" />
    </Style>

    <Style x:Key="searchButton" TargetType="Button" BasedOn="{StaticResource defaultButton}">
        <Setter Property="Content" Value="{x:Static resources:Resource.Search}" />
        <Setter Property="IsDefault" Value="True" />
    </Style>

    <Style TargetType="{x:Type ListBox}">
        <Setter Property="Margin" Value="2" />
    </Style>

    <Style TargetType="{x:Type wt:DatePicker}" BasedOn="{StaticResource errorTemplate}">
    </Style>

    <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource errorTemplate}">
        <Setter Property="Margin" Value="2" />
        <Setter Property="FontFamily" Value="Tahoma"/>
    </Style>

    <Style TargetType="{x:Type DatePicker}" BasedOn="{StaticResource errorTemplate}">
        <Setter Property="Margin" Value="2" />
    </Style>

    <Style TargetType="{x:Type ComboBox}" BasedOn="{StaticResource errorTemplate}">
        <Setter Property="Margin" Value="2" />
        <Setter Property="SelectedValuePath" Value="Data" />
    </Style>

    <Style TargetType="{x:Type PasswordBox}" BasedOn="{StaticResource errorTemplate}">
        <Setter Property="Margin" Value="2" />
    </Style>

    <Style TargetType="{x:Type xoqalControls:NumericTextBox}" BasedOn="{StaticResource errorTemplate}">
        <Setter Property="Margin" Value="2" />
    </Style>

    <Style TargetType="{x:Type xoqalControls:EnumCheckBoxList}" BasedOn="{StaticResource errorTemplate}">
        <Setter Property="Margin" Value="2" />
    </Style>

    <Style TargetType="{x:Type xoqalControls:EnumRadioList}" BasedOn="{StaticResource errorTemplate}">
        <Setter Property="Margin" Value="2" />
    </Style>

    <Style TargetType="TextBlock">
        <Style.Setters>
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="FontFamily" Value="Tahoma"/>
        </Style.Setters>
    </Style>

    <Style TargetType="CheckBox">
        <Style.Setters>
            <Setter Property="Margin" Value="2" />
        </Style.Setters>
    </Style>

    <Style x:Key="operationExpander" TargetType="{x:Type Expander}">
        <Style.Setters>
            <Setter Property="Header" Value="{x:Static resources:Resource.Operation}" />
            <Setter Property="ExpandDirection" Value="Up" />
            <Setter Property="Template" Value="{DynamicResource StretchyExpander}" />
        </Style.Setters>
    </Style>

    <ControlTemplate x:Key="AnimatedExpanderButtonTemp" TargetType="{x:Type ToggleButton}">
        <Border x:Name="ExpanderButtonBorder" Background="{TemplateBinding Background}"
            BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
            Padding="{TemplateBinding Padding}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Rectangle Fill="Transparent" Grid.ColumnSpan="2" />
                <Ellipse Name="Circle" Grid.Column="0" Stroke="DarkGray" Width="20" Height="20"
                 HorizontalAlignment="Center" VerticalAlignment="Center" />
                <Path x:Name="Arrow" Grid.Column="0" Data="M 1,1.5 L 4.5,5 8,1.5" Stroke="#FF666666"
              StrokeThickness="2" HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5">
                    <Path.RenderTransform>
                        <RotateTransform Angle="0" />
                    </Path.RenderTransform>
                </Path>
                <ContentPresenter x:Name="HeaderContent" Grid.Column="1" Margin="4,0,0,0" ContentSource="Content" />
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <!-- Animate arrow when toggled-->
            <Trigger Property="IsChecked" Value="True">
                <Trigger.EnterActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="Arrow"
                               Storyboard.TargetProperty="(Path.RenderTransform).(RotateTransform.Angle)" To="180" Duration="0:0:0.4" />
                        </Storyboard>
                    </BeginStoryboard>
                </Trigger.EnterActions>
                <Trigger.ExitActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="Arrow"
                               Storyboard.TargetProperty="(Path.RenderTransform).(RotateTransform.Angle)" To="0" Duration="0:0:0.4" />
                        </Storyboard>
                    </BeginStoryboard>
                </Trigger.ExitActions>
            </Trigger>

            <!-- MouseOver, Pressed behaviours-->
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Stroke" Value="#FF3C7FB1" TargetName="Circle" />
                <Setter Property="Stroke" Value="#222" TargetName="Arrow" />
            </Trigger>
            <Trigger Property="IsPressed" Value="true">
                <Setter Property="Stroke" Value="#FF526C7B" TargetName="Circle" />
                <Setter Property="StrokeThickness" Value="1.5" TargetName="Circle" />
                <Setter Property="Stroke" Value="#FF003366" TargetName="Arrow" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="StretchyExpander" TargetType="{x:Type Expander}">
        <DockPanel>
            <ToggleButton x:Name="ExpanderButton" DockPanel.Dock="Top"
                    Template="{StaticResource AnimatedExpanderButtonTemp}" Content="{TemplateBinding Header}"
                    IsChecked="{Binding Path=IsExpanded, RelativeSource={RelativeSource TemplatedParent}}" OverridesDefaultStyle="True"
                    Padding="1.5,0"></ToggleButton>
            <ContentPresenter x:Name="ExpanderContent" ContentSource="Content" DockPanel.Dock="Bottom">
                <ContentPresenter.LayoutTransform>
                    <ScaleTransform ScaleY="0" />
                </ContentPresenter.LayoutTransform>
            </ContentPresenter>
        </DockPanel>
        <ControlTemplate.Triggers>
            <Trigger Property="IsExpanded" Value="True">
                <Trigger.EnterActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="ExpanderContent"
                               Storyboard.TargetProperty="(ContentPresenter.LayoutTransform).(ScaleTransform.ScaleY)" To="1" Duration="0:0:0.4" />
                        </Storyboard>
                    </BeginStoryboard>
                </Trigger.EnterActions>
                <Trigger.ExitActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="ExpanderContent"
                               Storyboard.TargetProperty="(ContentPresenter.LayoutTransform).(ScaleTransform.ScaleY)" To="0" Duration="0:0:0.4" />
                        </Storyboard>
                    </BeginStoryboard>
                </Trigger.ExitActions>
            </Trigger>

        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="dataGridCell" TargetType="{x:Type DataGridCell}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridCell}">
                    <Grid Background="{TemplateBinding Background}">
                        <ContentPresenter VerticalAlignment="Center" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="formSimpleDataGrid" TargetType="xoqalControls:SimpleDataGrid" BasedOn="{StaticResource errorTemplate}">
        <Setter Property="AutoGenerateColumns" Value="False" />
        <Setter Property="EnableRowVirtualization" Value="True" />
        <Setter Property="VirtualizingStackPanel.IsVirtualizing" Value="True" />
        <Setter Property="VirtualizingStackPanel.VirtualizationMode" Value="Recycling" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="Margin" Value="5" />
        <Setter Property="VerticalAlignment" Value="Stretch" />
        <Setter Property="HorizontalGridLinesBrush" Value="LightGray" />
        <Setter Property="VerticalGridLinesBrush" Value="Gainsboro" />
        <Setter Property="IsReadOnly" Value="True" />
        <Setter Property="CellStyle" Value="{StaticResource dataGridCell}" />
    </Style>

    <Style TargetType="GridSplitter">
        <Setter Property="VerticalAlignment" Value="Stretch" />
        <Setter Property="ResizeBehavior" Value="PreviousAndNext" />
        <Setter Property="Width" Value="5" />
        <Setter Property="Background" Value="#FFE8D030" />
        <Setter Property="HorizontalAlignment" Value="Left" />
    </Style>
    
</ResourceDictionary>